<template>
  <div>
    <h3>{{msg.title}}</h3>
    <p class="subtitle">
      <span>发表时间：{{msg.add_time | dataFormat}}</span>
      <span>点击：{{msg.click}}次</span>
    </p>
    <!-- 缩略图区域 -->

    <!-- 图片内容区域 -->
    <div class="content" v-html="msg.content"></div>
    <!-- 评论子组件 -->
    <photo-comment :artid="msg.id"></photo-comment>
  </div>
</template>

<script>
// 导入公用的评论子组件
import comment from "../subcomponents/comment"
export default {
  data() {
    return {
      id: this.$route.params.id,
      msg: {}
    };
  },
  created() {
      this.getimgInfo();
  },
  methods: {
    getimgInfo() {
      this.$axios({
        method: "get",
        url: "http://www.liulongbin.top:3005/api/getimageInfo/" + this.id
      })
        .then(response => {
        //   console.log(response);
            if(response.data.status==0){
                this.msg = response.data.message[0];
            }else{
                this.showToastTime("数据获取失败");
            }
        })
        .catch(err => {
          if (err) {
              this.showToastTime("获取数据请求失败");
          }
        });
    },
    showToastTime(msg) {
      const toast = this.$createToast({
        time: 1000,
        txt: msg
      });
      toast.show();
    }
  },
  components: {
      "photo-comment":comment
  }
};
</script>

<style lang="less">
</style>